
//添加兴趣点-娱乐列表
var AddInterest_amusement = myApp.onPageInit("AddAmusement", function (page) {
    var filter_type = "";

    var source = JSON.parse(page.query.source);
    var dayName = page.query.dayName;
    var codes = [];
    var planDate = "";
    var planDayID = "";
    for (var i = 0; i < source.length; i++) {
        if (source[i].dayName == dayName) {
            codes[codes.length] = source[i].projectId;
            planDate = source[i].planDate;
            planDayID = source[i].planDayID;
        }
    }

    var loaderList = function () {
        var v_search = [];

        var v_longitude = "";
        var v_latitude = "";

        if (_isOpenPosition) {
            v_longitude = iss_localStorage.get("yuqing_longitude");
            v_latitude = iss_localStorage.get("yuqing_latitude");
        }
        else {
            v_longitude = iss_dictionaryBaseData.longitude;
            v_latitude = iss_dictionaryBaseData.latitude;
        }

        if (filter_type != "") {
            var opt = {
                SearchName: "类型",
                SearchField: "EntertainmentType",
                ConditionType: 1,
                AndOR: "and",
                ListSearchValue: [
                    {
                        ItemValue: filter_type
                    }
                ]
            };
            v_search.push(opt);
        }

        var _content = JSON.stringify({
            "type": 0,
            "conditionParams": {
                "Page": {
                    "PageSize": 10000,
                    "PageIndex": 1
                },
                "Search": v_search,
                "Order": []
            },
            lng: v_longitude,
            lat: v_latitude,
        })
        myApp.showPreloader();
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.WEB_ENTERTAINMEN,
            data: { "content": _content },
            crossDomain: true,
            dataType: "json",
            success: function (data, status) {
                myApp.hidePreloader();
                if (data && data.status == "0" && data.results && data.results.length > 0) {
                    data = data.results;
                    for (var i = 0; i < data.length; i++) {
                        data[i].isSelect = "false";
                        for (var j = 0; j < source.length; j++) {
                            if (source[j].dayName == dayName && source[j].projectId == data[i].code) {
                                data[i].isSelect = "true";
                                break;
                            }
                        }
                    }
                    var searchTemplate = $$('#interest-amusement-list').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        $$("#AddAmusement .amusement-list ul").html(html);

                        $$("#AddAmusement .amusement-list ul li").each(function () {
                            $$(this).on("click", function () {
                                var isSelect = $$(this).attr("isSelect");
                                if (isSelect == "false") {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/checked.png");
                                    $$(this).attr("isSelect", "true");
                                    for (var i = 0; i < source.length; i++) {
                                        if (parseInt(source[i].dayName) > dayName) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 3,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: "0.00",
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            if (source[i - 1].projectShortName == "") {
                                                source.splice(i - 1, 1, obj);
                                            } else {
                                                source.splice(i, 0, obj);
                                            }

                                            codes[codes.length] = $$(this).attr("code");
                                            break;
                                        }
                                        if (i == source.length - 1) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 3,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: "0.00",
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            source[source.length] = obj;
                                            codes[codes.length] = $$(this).attr("code");
                                        }
                                    }
                                } else {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/unchecked.png");
                                    $$(this).attr("isSelect", "false");
                                    for (var i = 0; i < source.length; i++) {
                                        if (source[i].dayName == dayName && source[i].projectId == $$(this).attr("code")) {
                                            codes.splice(i, 1);
                                            if (codes.length == 0) {
                                                source[i] = {
                                                    planProjectID: "",
                                                    projectType: "",
                                                    projectName: "",
                                                    projectShortName: "",
                                                    projectId: "",
                                                    PX: 1,
                                                    img: "",
                                                    remark: "",
                                                    time: "",
                                                    price: "0.00",
                                                    time4open: "",
                                                    address: "",
                                                    subAddress: "",
                                                    phone: "",
                                                    longitude: "",
                                                    latitude: "",
                                                    district: "",
                                                    isCollect: "",
                                                    planCollectID: "",
                                                    planDayID: planDayID,
                                                    planDate: planDate,
                                                    dayName: dayName,
                                                    attractionsStar: "",
                                                    hotelStar: "",
                                                    entertainmentType: ""
                                                }
                                            } else {
                                                source.splice(i, 1);
                                            }
                                            break;
                                        }
                                    }
                                }
                            })
                        })
                        $$("#AddAmusement .navbar .right").on("click", function () {
                            var px = 1;
                            for (var i = 0; i < source.length; i++) {
                                if (i == 0) {
                                    source[i].PX = 1;
                                } else {
                                    if (source[i].dayName != source[i - 1].dayName) {
                                        source[i].PX = 1;
                                        px = 1;
                                    } else {
                                        source[i].PX = ++px;
                                    }
                                }
                            }
                            iss_localStorage.set("yuqing_source", JSON.stringify(source));
                            mainView.router.reloadPreviousPage('../../view/SmartTravel/EditMySmartTravel.html');
                            mainView.router.back();
                        })
                    }
                } else {
                    if (pageindex == 1) {
                        $$("#AddAmusement .amusement-list ul").html(ISS_Element.DIV.noAnswer);
                        $$("#AddAmusement .amusement-list ul .noAnswer").on("click", function () {
                            loaderList();
                        });
                    }
                }
            },
            error: function () {
                myApp.hidePreloader();
                myApp.alert("服务器连接失败！");
            }
        })
    }

    loaderList();

    $$(".list-menu").hide();
    $$(".subnavbar .buttons-row a").click(function () {
        if (!$$(this).hasClass("active")) {
            $$(this).addClass("active");
            $$(".list-menu").show();
            // $$("#AddAmusement .menu1").removeClass("animation-hide");
            // $$("#AddAmusement .menu1").addClass("animation-show");
        } else {
            $$(this).removeClass("active");
            // $$("#AddAmusement .menu1").removeClass("animation-show");
            // $$("#AddAmusement .menu1").addClass("animation-hide");
            $$(".list-menu").hide();
        }
    });
    $$(".list-menu li").each(function () {
        $$(this).on("click", function () {
            $$(".list-menu li").removeClass("select");
            $$(this).addClass("select");
            $$(".subnavbar .buttons-row a").removeClass("active");
            $$(".list-menu").hide();
            $$(".subnavbar .buttons-row a").html($$(this).html());
            filter_type = $$(this).attr("value");
            loaderList();
        })
    })
});

//添加兴趣点-购物列表
var AddInterest_business = myApp.onPageInit("AddBusiness", function (page) {
    var filter_type = "";
    var source = JSON.parse(page.query.source);
    var dayName = page.query.dayName;
    var codes = [];
    var planDate = "";
    var planDayID = "";
    for (var i = 0; i < source.length; i++) {
        if (source[i].dayName == dayName) {
            codes[codes.length] = source[i].projectId;
            planDate = source[i].planDate;
            planDayID = source[i].planDayID;
        }
    }

    var loaderList = function () {
        var v_search = [];

        var v_longitude = "";
        var v_latitude = "";

        if (_isOpenPosition) {
            v_longitude = iss_localStorage.get("yuqing_longitude");
            v_latitude = iss_localStorage.get("yuqing_latitude");
        }
        else {
            v_longitude = iss_dictionaryBaseData.longitude;
            v_latitude = iss_dictionaryBaseData.latitude;
        }

        if (filter_type != "") {
            var opt = {
                SearchName: "类型",
                SearchField: "BusinessType",
                ConditionType: 1,
                AndOR: "and",
                ListSearchValue: [
                    {
                        ItemValue: filter_type
                    }
                ]
            };
            v_search.push(opt);
        }

        var _content = JSON.stringify({
            "type": 0,
            "conditionParams": {
                "Page": {
                    "PageSize": 10000,
                    "PageIndex": 1
                },
                "Search": v_search,
                "Order": []
            },
            lng: v_longitude,
            lat: v_latitude,
        })
        myApp.showPreloader();
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.BUSINESS,
            data: { "content": _content },
            crossDomain: true,
            dataType: "json",
            success: function (data, status) {
                myApp.hidePreloader();
                if (data && data.status == "0" && data.results && data.results.length > 0) {
                    data = data.results;
                    for (var i = 0; i < data.length; i++) {
                        data[i].isSelect = "false";
                        for (var j = 0; j < source.length; j++) {
                            if (source[j].dayName == dayName && source[j].projectId == data[i].code) {
                                data[i].isSelect = "true";
                                break;
                            }
                        }
                    }
                    var searchTemplate = $$('#interest-business-list').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        $$("#AddBusiness .business-list ul").html(html);

                        $$("#AddBusiness .business-list ul li").each(function () {
                            $$(this).on("click", function () {
                                var isSelect = $$(this).attr("isSelect");
                                if (isSelect == "false") {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/checked.png");
                                    $$(this).attr("isSelect", "true");
                                    for (var i = 0; i < source.length; i++) {
                                        if (parseInt(source[i].dayName) > dayName) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 4,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: "0.00",
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            if (source[i - 1].projectShortName == "") {
                                                source.splice(i - 1, 1, obj);
                                            } else {
                                                source.splice(i, 0, obj);
                                            }

                                            codes[codes.length] = $$(this).attr("code");
                                            break;
                                        }
                                        if (i == source.length - 1) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 4,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: "0.00",
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            source[source.length] = obj;
                                            codes[codes.length] = $$(this).attr("code");
                                        }
                                    }
                                } else {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/unchecked.png");
                                    $$(this).attr("isSelect", "false");
                                    for (var i = 0; i < source.length; i++) {
                                        if (source[i].dayName == dayName && source[i].projectId == $$(this).attr("code")) {
                                            codes.splice(i, 1);
                                            if (codes.length == 0) {
                                                source[i] = {
                                                    planProjectID: "",
                                                    projectType: "",
                                                    projectName: "",
                                                    projectShortName: "",
                                                    projectId: "",
                                                    PX: 1,
                                                    img: "",
                                                    remark: "",
                                                    time: "",
                                                    price: "0.00",
                                                    time4open: "",
                                                    address: "",
                                                    subAddress: "",
                                                    phone: "",
                                                    longitude: "",
                                                    latitude: "",
                                                    district: "",
                                                    isCollect: "",
                                                    planCollectID: "",
                                                    planDayID: planDayID,
                                                    planDate: planDate,
                                                    dayName: dayName,
                                                    attractionsStar: "",
                                                    hotelStar: "",
                                                    entertainmentType: ""
                                                }
                                            } else {
                                                source.splice(i, 1);
                                            }
                                            break;
                                        }
                                    }
                                }
                            })
                        })
                        $$("#AddBusiness .navbar .right").on("click", function () {
                            var px = 1;
                            for (var i = 0; i < source.length; i++) {
                                if (i == 0) {
                                    source[i].PX = 1;
                                } else {
                                    if (source[i].dayName != source[i - 1].dayName) {
                                        source[i].PX = 1;
                                        px = 1;
                                    } else {
                                        source[i].PX = ++px;
                                    }
                                }
                            }
                            iss_localStorage.set("yuqing_source", JSON.stringify(source));
                            mainView.router.reloadPreviousPage('../../view/SmartTravel/EditMySmartTravel.html');
                            mainView.router.back('../../view/SmartTravel/EditMySmartTravel.html');
                        })
                    }
                } else {
                    if (pageindex == 1) {
                        $$("#AddBusiness .business-list ul").html(ISS_Element.DIV.noAnswer);
                        $$("#AddBusiness .business-list ul .noAnswer").on("click", function () {
                            loaderList();
                        });
                    }
                }
            },
            error: function () {
                myApp.hidePreloader();
                myApp.alert("服务器连接失败！");
            }
        })
    }

    loaderList();

    $$(".list-menu").hide();
    $$(".subnavbar .buttons-row a").click(function () {
        if (!$$(this).hasClass("active")) {
            $$(this).addClass("active");
            $$(".list-menu").show();
            // $$("#AddAmusement .menu1").removeClass("animation-hide");
            // $$("#AddAmusement .menu1").addClass("animation-show");
        } else {
            $$(this).removeClass("active");
            // $$("#AddAmusement .menu1").removeClass("animation-show");
            // $$("#AddAmusement .menu1").addClass("animation-hide");
            $$(".list-menu").hide();
        }
    });
    $$(".list-menu li").each(function () {
        $$(this).on("click", function () {
            $$(".list-menu li").removeClass("select");
            $$(this).addClass("select");
            $$(".subnavbar .buttons-row a").removeClass("active");
            $$(".list-menu").hide();
            $$(".subnavbar .buttons-row a").html($$(this).html());
            filter_type = $$(this).attr("value");
            loaderList();
        })
    })
});

//添加兴趣点-酒店列表
var AddInterest_hotel = myApp.onPageInit("AddHotel", function (page) {
    var filter_level = "";
    var filter_price = "";

    var source = JSON.parse(page.query.source);
    var dayName = page.query.dayName;
    var codes = [];
    var planDate = "";
    var planDayID = "";
    for (var i = 0; i < source.length; i++) {
        if (source[i].dayName == dayName) {
            codes[codes.length] = source[i].projectId;
            planDate = source[i].planDate;
            planDayID = source[i].planDayID;
        }
    }

    var loaderList = function () {
        var v_search = [];

        var v_longitude = "";
        var v_latitude = "";

        if (_isOpenPosition) {
            v_longitude = iss_localStorage.get("yuqing_longitude");
            v_latitude = iss_localStorage.get("yuqing_latitude");
        }
        else {
            v_longitude = iss_dictionaryBaseData.longitude;
            v_latitude = iss_dictionaryBaseData.latitude;
        }

        if (filter_level != "") {
            v_search.push(
                {
                    SearchField: "Star",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: filter_level
                        }
                    ]
                }
            );

        }

        if (filter_price != "") {
            v_search.push(
                {
                    SearchField: "Price",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: filter_price
                        }
                    ]
                }
            );
        }

        var _content = JSON.stringify({
            "type": 0,
            "conditionParams": {
                "Page": {
                    "PageSize": 10000,
                    "PageIndex": 1
                },
                "Search": v_search,
                "Order": []
            },
            lng: v_longitude,
            lat: v_latitude,
        })
        myApp.showPreloader();
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.HOTEL,
            data: { "content": _content },
            crossDomain: true,
            dataType: "json",
            success: function (data, status) {
                myApp.hidePreloader();
                if (data && data.status == "0" && data.results && data.results.length > 0) {
                    data = data.results;
                    for (var i = 0; i < data.length; i++) {
                        data[i].isSelect = "false";
                        for (var j = 0; j < source.length; j++) {
                            if (source[j].dayName == dayName && source[j].projectId == data[i].code) {
                                data[i].isSelect = "true";
                                break;
                            }
                        }
                    }
                    var searchTemplate = $$('#interest-hotel-list').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        $$("#AddHotel .hotel-list ul").html(html);

                        $$("#AddHotel .hotel-list ul li").each(function () {
                            $$(this).on("click", function () {
                                var isSelect = $$(this).attr("isSelect");
                                if (isSelect == "false") {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/checked.png");
                                    $$(this).attr("isSelect", "true");
                                    for (var i = 0; i < source.length; i++) {
                                        if (parseInt(source[i].dayName) > dayName) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 1,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: $$(this).attr("price"),
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            if (source[i - 1].projectShortName == "") {                                    
                                                source.splice(i - 1, 1, obj);
                                            } else {
                                                source.splice(i, 0, obj);
                                            }

                                            codes[codes.length] = $$(this).attr("code");
                                            break;
                                        }
                                        if (i == source.length - 1) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 1,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: $$(this).attr("price"),
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            source[source.length] = obj;
                                            codes[codes.length] = $$(this).attr("code");
                                        }
                                    }
                                } else {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/unchecked.png");
                                    $$(this).attr("isSelect", "false");
                                    for (var i = 0; i < source.length; i++) {
                                        if (source[i].dayName == dayName && source[i].projectId == $$(this).attr("code")) {
                                            codes.splice(i, 1);
                                            if (codes.length == 0) {
                                                source[i] = {
                                                    planProjectID: "",
                                                    projectType: "",
                                                    projectName: "",
                                                    projectShortName: "",
                                                    projectId: "",
                                                    PX: 1,
                                                    img: "",
                                                    remark: "",
                                                    time: "",
                                                    price: $$(this).attr("price"),
                                                    time4open: "",
                                                    address: "",
                                                    subAddress: "",
                                                    phone: "",
                                                    longitude: "",
                                                    latitude: "",
                                                    district: "",
                                                    isCollect: "",
                                                    planCollectID: "",
                                                    planDayID: planDayID,
                                                    planDate: planDate,
                                                    dayName: dayName,
                                                    attractionsStar: "",
                                                    hotelStar: "",
                                                    entertainmentType: ""
                                                }
                                            } else {
                                                source.splice(i, 1);
                                            }
                                            break;
                                        }
                                    }
                                }
                            })
                        })
                        $$("#AddHotel .navbar .right").on("click", function () {
                            var px = 1;
                            for (var i = 0; i < source.length; i++) {
                                if (i == 0) {
                                    source[i].PX = 1;
                                } else {
                                    if (source[i].dayName != source[i - 1].dayName) {
                                        source[i].PX = 1;
                                        px = 1;
                                    } else {
                                        source[i].PX = ++px;
                                    }
                                }
                            }
                            iss_localStorage.set("yuqing_source", JSON.stringify(source));
                            mainView.router.reloadPreviousPage('../../view/SmartTravel/EditMySmartTravel.html');
                            mainView.router.back();
                        })

                    }
                } else {
                    if (pageindex == 1) {
                        $$("#AddHotel .hotel-list ul").html(ISS_Element.DIV.noAnswer);
                        $$("#AddHotel .hotel-list ul .noAnswer").on("click", function () {
                            loaderList();
                        });
                    }
                }
            },
            error: function () {
                myApp.hidePreloader();
                myApp.alert("服务器连接失败！");
            }
        })
    }

    loaderList();

    $$(".list-menu").hide();
    $$(".subnavbar .buttons-row a").click(function () {
        if (!$$(this).hasClass("active")) {
            $$(this).addClass("active");
            if ($$(this).index() == 0) {
                $$(".subnavbar .buttons-row a").eq(1).removeClass("active");
                $$(".menu1").show();
                $$(".menu2").hide();
            } else {
                $$(".subnavbar .buttons-row a").eq(0).removeClass("active");
                $$(".menu1").hide();
                $$(".menu2").show();
            }

            // $$("#AddAmusement .menu1").removeClass("animation-hide");
            // $$("#AddAmusement .menu1").addClass("animation-show");
        } else {
            $$(this).removeClass("active");
            // $$("#AddAmusement .menu1").removeClass("animation-show");
            // $$("#AddAmusement .menu1").addClass("animation-hide");
            $$(".list-menu").hide();
        }
    });

    $$(".menu1 li").each(function () {
        $$(this).on("click", function () {
            $$(".menu1 li").removeClass("select");
            $$(this).addClass("select");
            $$(".subnavbar .buttons-row a").removeClass("active");
            $$(".menu1").hide();
            $$(".subnavbar .buttons-row a").eq(0).html($$(this).html());
            filter_level = $$(this).attr("value");
            loaderList();
        })
    })

    $$(".menu2 li").each(function () {
        $$(this).on("click", function () {
            $$(".menu2 li").removeClass("select");
            $$(this).addClass("select");
            $$(".subnavbar .buttons-row a").removeClass("active");
            $$(".menu2").hide();
            $$(".subnavbar .buttons-row a").eq(1).html($$(this).html());
            filter_type = $$(this).attr("value");
            loaderList();
        })
    })
});

//添加兴趣点-景区列表
var AddInterest_scenic = myApp.onPageInit("AddScenic", function (page) {

    var filter_level = "";
    var filter_type = "";

    var source = JSON.parse(page.query.source);
    var dayName = page.query.dayName;
    var codes = [];
    var planDate = "";
    var planDayID = "";
    for (var i = 0; i < source.length; i++) {
        if (source[i].dayName == dayName) {
            codes[codes.length] = source[i].projectId;
            planDate = source[i].planDate;
            planDayID = source[i].planDayID;
        }
    }

    var loaderList = function () {

        var v_longitude = "";
        var v_latitude = "";

        var v_search = [];

        if (_isOpenPosition) {
            v_longitude = iss_localStorage.get("yuqing_longitude");
            v_latitude = iss_localStorage.get("yuqing_latitude");
        }
        else {
            v_longitude = iss_dictionaryBaseData.longitude;
            v_latitude = iss_dictionaryBaseData.latitude;
        }

        if (filter_level != "") {
            v_search.push(
                {
                    SearchField: "AttrRating",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: filter_level
                        }
                    ]
                }
            );

        }

        if (filter_type != "") {
            v_search.push(
                {
                    SearchField: "AttrType",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: filter_type
                        }
                    ]
                }
            );
        }

        var _content = JSON.stringify({
            "type": 0,
            "conditionParams": {
                "Page": {
                    "PageSize": 10000,
                    "PageIndex": 1
                },
                "Search": v_search,
                "Order": []
            },
            lng: v_longitude,
            lat: v_latitude,
        })


        myApp.showPreloader();
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR,
            data: { "content": _content },
            crossDomain: true,
            dataType: "json",
            success: function (data, status) {
                myApp.hidePreloader();
                if (data && data.status == "0" && data.results && data.results.length > 0) {
                    data = data.results;
                    for (var i = 0; i < data.length; i++) {
                        data[i].isSelect = "false";
                        for (var j = 0; j < source.length; j++) {
                            if (source[j].dayName == dayName && source[j].projectId == data[i].code) {
                                data[i].isSelect = "true";
                                break;
                            }
                        }
                    }
                    var searchTemplate = $$('#interest-scenic-list').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        $$("#AddScenic .scenic-list ul").html(html);

                        $$("#AddScenic .scenic-list ul li").each(function () {
                            $$(this).on("click", function () {
                                var isSelect = $$(this).attr("isSelect");
                                if (isSelect == "false") {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/checked.png");
                                    $$(this).attr("isSelect", "true");
                                    for (var i = 0; i < source.length; i++) {
                                        if (parseInt(source[i].dayName) > dayName) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 0,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: $$(this).attr("price"),
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            if (source[i - 1].projectShortName == "") {
                                                source.splice(i - 1, 1, obj);
                                            } else {
                                                source.splice(i, 0, obj);
                                            }

                                            codes[codes.length] = $$(this).attr("code");
                                            break;
                                        }
                                        if (i == source.length - 1) {
                                            var obj = {
                                                planProjectID: "",
                                                projectType: 0,
                                                projectName: $$(this).attr("cnName"),
                                                projectShortName: $$(this).attr("cnName"),
                                                projectId: $$(this).attr("code"),
                                                PX: 1,
                                                img: "",
                                                remark: "",
                                                time: "",
                                                price: $$(this).attr("price"),
                                                time4open: "",
                                                address: "",
                                                subAddress: "",
                                                phone: "",
                                                longitude: $$(this).attr("longitude"),
                                                latitude: $$(this).attr("latitude"),
                                                district: "",
                                                isCollect: "",
                                                planCollectID: "",
                                                planDayID: planDayID,
                                                planDate: planDate,
                                                dayName: dayName,
                                                attractionsStar: "",
                                                hotelStar: "",
                                                entertainmentType: ""
                                            }
                                            source[source.length] = obj;
                                            codes[codes.length] = $$(this).attr("code");
                                        }
                                    }
                                } else {
                                    $$(this).find(".checkbox img").attr("src", "../../assets/images/images-yuqing/address/unchecked.png");
                                    $$(this).attr("isSelect", "false");
                                    for (var i = 0; i < source.length; i++) {
                                        if (source[i].dayName == dayName && source[i].projectId == $$(this).attr("code")) {
                                            codes.splice(i, 1);
                                            if (codes.length == 0) {
                                                source[i] = {
                                                    planProjectID: "",
                                                    projectType: "",
                                                    projectName: "",
                                                    projectShortName: "",
                                                    projectId: "",
                                                    PX: 1,
                                                    img: "",
                                                    remark: "",
                                                    time: "",
                                                    price: $$(this).attr("price"),
                                                    time4open: "",
                                                    address: "",
                                                    subAddress: "",
                                                    phone: "",
                                                    longitude: "",
                                                    latitude: "",
                                                    district: "",
                                                    isCollect: "",
                                                    planCollectID: "",
                                                    planDayID: planDayID,
                                                    planDate: planDate,
                                                    dayName: dayName,
                                                    attractionsStar: "",
                                                    hotelStar: "",
                                                    entertainmentType: ""
                                                }
                                            } else {
                                                source.splice(i, 1);
                                            }
                                            break;
                                        }
                                    }
                                }
                            })
                        })
                        $$("#AddScenic .navbar .right").on("click", function () {
                            var px = 1;
                            for (var i = 0; i < source.length; i++) {
                                if (i == 0) {
                                    source[i].PX = 1;
                                } else {
                                    if (source[i].dayName != source[i - 1].dayName) {
                                        source[i].PX = 1;
                                        px = 1;
                                    } else {
                                        source[i].PX = ++px;
                                    }
                                }
                            }
                            iss_localStorage.set("yuqing_source", JSON.stringify(source));
                            mainView.router.reloadPreviousPage('../../view/SmartTravel/EditMySmartTravel.html');
                            mainView.router.back();
                        })

                    }
                } else {
                    if (pageindex == 1) {
                        $$("#AddScenic .scenic-list ul").html(ISS_Element.DIV.noAnswer);
                        $$("#AddScenic .scenic-list ul .noAnswer").on("click", function () {
                            loaderList();
                        });
                    }
                }
            },
            error: function () {
                myApp.hidePreloader();
                myApp.alert("服务器连接失败！");
            }
        })
    }

    loaderList();

    $$(".list-menu").hide();
    $$(".subnavbar .buttons-row a").click(function () {
        if (!$$(this).hasClass("active")) {
            $$(this).addClass("active");
            if ($$(this).index() == 0) {
                $$(".subnavbar .buttons-row a").eq(1).removeClass("active");
                $$(".menu1").show();
                $$(".menu2").hide();
            } else {
                $$(".subnavbar .buttons-row a").eq(0).removeClass("active");
                $$(".menu1").hide();
                $$(".menu2").show();
            }

            // $$("#AddAmusement .menu1").removeClass("animation-hide");
            // $$("#AddAmusement .menu1").addClass("animation-show");
        } else {
            $$(this).removeClass("active");
            // $$("#AddAmusement .menu1").removeClass("animation-show");
            // $$("#AddAmusement .menu1").addClass("animation-hide");
            $$(".list-menu").hide();
        }
    });

    $$(".menu1 li").each(function () {
        $$(this).on("click", function () {
            $$(".menu1 li").removeClass("select");
            $$(this).addClass("select");
            $$(".subnavbar .buttons-row a").removeClass("active");
            $$(".menu1").hide();
            $$(".subnavbar .buttons-row a").eq(0).html($$(this).html());
            filter_level = $$(this).attr("value");
            loaderList();
        })
    })

    $$(".menu2 li").each(function () {
        $$(this).on("click", function () {
            $$(".menu2 li").removeClass("select");
            $$(this).addClass("select");
            $$(".subnavbar .buttons-row a").removeClass("active");
            $$(".menu2").hide();
            $$(".subnavbar .buttons-row a").eq(1).html($$(this).html());
            filter_type = $$(this).attr("value");
            loaderList();
        })
    })
});

